package org.veridiandynamics.client.view;

import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Dimension;

import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.border.Border;

/**
 * This class saves me rewriting same code over and over again in my gui screens.
 * 
 * @author Lee
 *
 */
public abstract class AbstractPanelLayout extends JPanel
{
	private static final long serialVersionUID = 1L;
	public JPanel panelLeft;
	public JPanel panelCenter;
	public JPanel panelEast;
	public int numCenterPanels = 3;
	public JPanel baseCard;
	public CardLayout c1;
	public static final int XSIZE = 650;
	public static final int YSIZE = 450;
	
	/**
	 *  Constructor for the abstract layout.
	 */
	public AbstractPanelLayout() {
	}
	
	/**
	 * Initializes common information on the panels.
	 */
	public void initialize()
	{	
		c1 = new CardLayout();
		setLayout(c1);
		baseCard = new JPanel();
		add(baseCard, "BASECARD");

		//west-center panel
		panelLeft = new JPanel();
		baseCard.add(panelLeft);
		if (numCenterPanels == 1)
			setPreferredSize(new Dimension(XSIZE, YSIZE));

		//center-center panel
		if (numCenterPanels == 2)
		{
			panelLeft.setPreferredSize(new Dimension(XSIZE /2, YSIZE));
			panelCenter = new JPanel();
			panelCenter.setPreferredSize(new Dimension(XSIZE /2, YSIZE));
			baseCard.add(panelCenter);
		}
		if (numCenterPanels == 3)
		{
			panelCenter = new JPanel();
			Border pb = BorderFactory.createLineBorder(Color.BLACK, 2);
			panelCenter.setBorder(pb);
			baseCard.add(panelCenter);
			panelEast = new JPanel();
			baseCard.add(panelEast);
			panelLeft.setPreferredSize(new Dimension(XSIZE /3, YSIZE));
			panelCenter.setPreferredSize(new Dimension(XSIZE /3, YSIZE));
			panelEast.setPreferredSize(new Dimension(XSIZE /3, YSIZE));
		}
	}
}
